package com.otupia.acs.locator;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.cvlep.appbase.locator.Locator;

public final class EJBLocator implements Locator
{
	//private static final String EJB_CONFIG_FILE = "com.otupia.acs.config.EJB.properties";
	/*private static final Configuration ACS_EJB_Config= ConfigUtils.loadConfig(
			EJB_CONFIG_FILE, ConfigurationFileType.PROPERTIES);*/

	public static InitialContext con;

	public EJBLocator()
	{
		System.out
				.println("******************initial EJB locator start ******************");
		/*Properties prop = new Properties();
		String factoryKey = ACS_EJB_Config.getString("java.naming.factory.key");
		String factoryValue = ACS_EJB_Config.getString("java.naming.factory.value");
		String providerKey = ACS_EJB_Config.getString("provider.key");
		String providerValue = ACS_EJB_Config.getString("provider.value");

		System.out.println("factoryKey :: " + factoryKey);
		System.out.println("factoryValue :: " + factoryValue);
		System.out.println("providerKey :: " + providerKey);
		System.out.println("providerValue :: " + providerValue);

		prop.put(factoryKey, factoryValue);
		prop.put(providerKey, providerValue);

		try
		{
			con = new InitialContext(prop);
		} catch (NamingException e)
		{
			e.printStackTrace();
		}*/
		System.out
				.println("******************initial EJB locator end ******************");
	}

	public Object getBean(String name)
	{
		Object remoteObj = null;
		try
		{
			remoteObj = con.lookup(name);
		} catch (NamingException e)
		{
			e.printStackTrace();
		}

		return remoteObj;
	}
}
